#include <iostream>
#include <vector>
#include <map>
#include <sstream>
#include <algorithm>

int main()
{
    std::map<int, std::string> mp = {{1, "1"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"}, {8, "8"}, {9, "9"}, {10, "10"}, {11, "J"}, {12, "Q"}, {13, "K"}, {14, "A"}};

    std::string s;
    std::getline(std::cin, s);
    std::istringstream iss(s);

    std::string tok;
    std::vector<int> nums;
    while (std::getline(iss, tok, ' '))
    {
        if (tok == "10")
        {
            nums.push_back(10);
        }
        else
        {
            char c = tok[0];
            if (c > '2' && c <= '9')
            {
                nums.push_back(c - '0');
            }
            else if (c == 'J')
            {
                nums.push_back(11);
            }
            else if (c == 'Q')
            {
                nums.push_back(12);
            }
            else if (c == 'K')
            {
                nums.push_back(13);
            }
            else if (c == 'A')
            {
                nums.push_back(14);
            }
        }
    }

    std::sort(nums.begin(), nums.end());
    std::vector<std::vector<int>> ret_vec;
    std::vector<bool> used(nums.size(), false);

    for (int i = 0; i < nums.size(); i++)
    {
        if (used[i])
            continue;
        used[i] = true;
        std::vector<int> tv;
        tv.push_back(nums[i]);

        int j = i + 1;
        while (j < nums.size())
        {
            if (used[j])
                continue;
            if (nums[j] - nums[j - 1] == 1)
            {
                tv.push_back(nums[j]);
                used[j] = true;
                j++;
            }
            else
            {
                break;
            }
        }
        if (tv.size() >= 5)
        {
            ret_vec.push_back(tv);
        }
    }

    if (ret_vec.size() == 0)
        std::cout << "NO" << std::endl;
    else
    {
        for (int i = 0; i < ret_vec.size(); i++)
        {
            for (int j = 0; j < ret_vec[i].size(); j++)
            {
                std::cout << mp[ret_vec[i][j]] << " ";
            }
            std::cout << std::endl;
        }
    }

    return 0;
}